package com.gec.zhs.controller;

import java.util.List;

import com.gec.zhs.entity.query.RelevanceQuery;
import com.gec.zhs.entity.po.Relevance;
import com.gec.zhs.entity.vo.ResponseVO;
import com.gec.zhs.service.RelevanceService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 多对多关系集中映射 Controller
 */
@RestController("relevanceController")
@RequestMapping("/relevance")
public class RelevanceController extends ABaseController{

	@Resource
	private RelevanceService relevanceService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(RelevanceQuery query){
		return getSuccessResponseVO(relevanceService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(Relevance bean) {
		relevanceService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<Relevance> listBean) {
		relevanceService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<Relevance> listBean) {
		relevanceService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询对象
	 */
	@RequestMapping("/getRelevanceById")
	public ResponseVO getRelevanceById(String id) {
		return getSuccessResponseVO(relevanceService.getRelevanceById(id));
	}

	/**
	 * 根据Id修改对象
	 */
	@RequestMapping("/updateRelevanceById")
	public ResponseVO updateRelevanceById(Relevance bean,String id) {
		relevanceService.updateRelevanceById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("/deleteRelevanceById")
	public ResponseVO deleteRelevanceById(String id) {
		relevanceService.deleteRelevanceById(id);
		return getSuccessResponseVO(null);
	}
}